<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 16] SimpleDateFormat</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 17:32:07 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch16_17.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 16<br>The java.text Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch16_19.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>SimpleDateFormat</H1>

<H2>Name</H2>

SimpleDateFormat

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.128">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.text.SimpleDateFormat</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.text.DateFormat</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
New as of JDK 1.1 </DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.129">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>SimpleDateFormat</tt> class 
is a concrete subclass of <tt CLASS=literal>DateFormat</tt> 
that formats and parses dates and times using a formatting pattern. Typically, 
you do not need to instantiate <tt CLASS=literal>SimpleDateFormat</tt> 
yourself. Instead, the factory methods of <tt CLASS=literal>DateFormat</tt> 
return instances of <tt CLASS=literal>SimpleDateFormat</tt> 
that are appropriate for particular locales. 

<P CLASS=para>
However, if you need a specialized date and time format, you can instantiate 
your own <tt CLASS=literal>SimpleDateFormat</tt> using 
a pattern string. You can also modify the formatting pattern of an existing 
<tt CLASS=literal>SimpleDateFormat</tt> object using 
the <tt CLASS=literal>applyPattern()</tt> method. 
The following symbols are significant in the pattern string. 

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="LEFT">Symbol</TH>
<TH ALIGN="LEFT">Description</TH>
<TH ALIGN="LEFT">Example</TH>
<TH ALIGN="LEFT">Type</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>G</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Era</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
AD</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Text</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>y</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Year</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
1997</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>M</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Month in year</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
3 or March</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Text or numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>d</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Day in month</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
4</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>h</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Hour in A.M./P.M. (1-12)</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
2</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>H</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Hour in day (0-23)</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
14</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>m</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Minute in hour</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
33</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>s</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Second in minute</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
21</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>S</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Milliseconds</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
333</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>E</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Day of week</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Thursday</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Text</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>D</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Day in year</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
63</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>F</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Day of week of month</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
1</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>w</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Week in year</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
9</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>W</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Week in month</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
1</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>a</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
A.M./P.M.</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
P.M.</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Text</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>k</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Hour in day (1-24)</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
14</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>K</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Hour in A.M./P.M. (0-11)</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
2</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Numeric</TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>z</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Time zone</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
EST</TD>
<TD ALIGN="LEFT">

<P CLASS=para>
Text</TD>
</TR>
</TABLE>
<P>
</DIV>

<P CLASS=para>
Symbols that are numeric can be repeated to specify a minimum number of 
digits. For example, <tt CLASS=literal>"hh"</tt> 
produces an hour field that is always at least two digits, like <tt CLASS=literal>"02"</tt>. 
Symbols that are textual can be repeated to specify whether the short form 
or the long form of the text string is used, if there are both short and 
long forms. If four or more symbols are specified, the long form is used; 
otherwise the short form is used. For example, <tt CLASS=literal>"E"</tt> 
produces a short form of the day of the week, 
such as <tt CLASS=literal>"Tue"</tt>, 
while <tt CLASS=literal>"EEEE"</tt> produces 
the long form, such as <tt CLASS=literal>"Tuesday"</tt>. 
For the month of the year, if one or two <tt CLASS=literal>"M"</tt> 
symbols are used, the field is numeric. If three or 
more <tt CLASS=literal>"M"</tt> 
symbols are used, the field is textual. 

<P CLASS=para>
Single quotes can be used to specify literal text that should be included 
in the formatted output, and any unrecognized symbol is treated as literal 
text. For example, the following pattern: 

<DIV CLASS=screen>
<P>
<PRE>
hh:mm a 'in the' zzzz 'zone.'
</PRE>
</DIV>

<P CLASS=para>
produces output like: 

<DIV CLASS=screen>
<P>
<PRE>
02:33 PM in the Eastern Standard Time zone.
</PRE>
</DIV>

<P CLASS=para>
Internally, the <tt CLASS=literal>SimpleDataFormat</tt> 
class uses a <tt CLASS=literal>DateFormatSymbols</tt> 
object to get the date and time strings that are appropriate for a particular 
locale. If you want to modify these strings, you can get the <tt CLASS=literal>DateFormatSymbols</tt> 
object by calling <tt CLASS=literal>getDateFormatSymbols()</tt>. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.130">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.text.SimpleDateFormat  extends java.text.DateFormat {
  // Constructors
  public SimpleDateFormat();
  public SimpleDateFormat(String pattern);
  public SimpleDateFormat(String pattern, Locale loc);
  public SimpleDateFormat(String pattern, DateFormatSymbols formatData);
  // Instance Methods
  public void applyLocalizedPattern(String pattern);
  public void applyPattern(String pattern);
  public Object clone();
  public boolean equals(Object obj); 
  public StringBuffer format(Date date, StringBuffer toAppendTo, 
                      FieldPosition pos); 
  public DateFormatSymbols getDateFormatSymbols();
  public int hashCode();
  public Date parse(String text, ParsePosition pos); 
  public void setDateFormatSymbols(DateFormatSymbols newFormatSymbols);
  public String toLocalizedPattern();
  public String toPattern();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.131">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.246">SimpleDateFormat</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.284">public SimpleDateFormat()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>SimpleDateFormat</tt> 
that uses a default formatting pattern and <tt CLASS=literal>DateFormatSymbols</tt> 
that are appropriate for the default locale. It produces the same result 
as calling <tt CLASS=literal>DateFormat.getDateTimeInstance(DateFormat.SHORT,</tt>  
<tt CLASS=literal>DateFormat.SHORT)</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.285">public SimpleDateFormat(String pattern)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>pattern</tt><br>
<DD>

<P CLASS=para>
The pattern string. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>SimpleDateFormat</tt> 
that uses the given formatting pattern and a <tt CLASS=literal>DateFormatSymbols</tt> object
that is appropriate for the default locale. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.286">public SimpleDateFormat(String pattern, Locale loc)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>pattern</tt><br>
<DD>

<P CLASS=para>
The pattern string.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>loc</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Locale</tt> to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>SimpleDateFormat</tt> 
that uses the given formatting pattern and a <tt CLASS=literal>DateFormatSymbols</tt> object
that is appropriate for the 
given locale. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.287"><DIV CLASS=screen> <P> <PRE> public SimpleDateFormat(String pattern, DateFormatSymbols formatData) </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>pattern</tt><br>
<DD>

<P CLASS=para>
The pattern string.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>formatData</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>DateFormatSymbols</tt> to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This constructor creates a <tt CLASS=literal>SimpleDateFormat</tt> 
that uses the given formatting pattern and <tt CLASS=literal>DateFormatSymbols</tt> 
object. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.132">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.247">applyLocalizedPattern</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.288">public void applyLocalizedPattern(String pattern)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>pattern</tt><br>
<DD>

<P CLASS=para>
The pattern string. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method tells this <tt CLASS=literal>SimpleDateFormat</tt> 
to use the given formating pattern to format and parse dates and times. 
The pattern string is assumed to have been localized to the <tt CLASS=literal>DateFormatSymbols</tt> 
object this <tt CLASS=literal>SimpleDateFormat</tt> 
uses. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.248">applyPattern</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.289">public void applyPattern(String pattern)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>pattern</tt><br>
<DD>

<P CLASS=para>
The pattern string. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method tells this <tt CLASS=literal>SimpleDateFormat</tt> 
to use the given formatting pattern to format and parse dates and times. 
The pattern string is localized to the <tt CLASS=literal>DateFormatSymbols</tt> 
object this <tt CLASS=literal>SimpleDateFormat</tt> 
uses. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.249">clone</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.290">public Object clone()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A copy of this <tt CLASS=literal>SimpleDateFormat</tt>. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DateFormat.clone()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method creates a copy of this <tt CLASS=literal>SimpleDateFormat</tt> 
and returns it. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.250">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.291">public boolean equals(Object obj)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>obj</tt><br>
<DD>

<P CLASS=para>
The object to be compared 
with this object. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the objects are equal; 
<tt CLASS=literal>false</tt> if they are not. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DateFormat.equals()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if 
<tt CLASS=literal>obj</tt> is an instance of <tt CLASS=literal>SimpleDateFormat</tt> 
and is equivalent to this <tt CLASS=literal>SimpleDateFormat</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.251">format</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.292"><DIV CLASS=screen> <P> <PRE> public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>date</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Date</tt> 
object to be formatted.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>toAppendTo</tt><br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>StringBuffer</tt> 
on which to append the formatted information.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>pos</tt><br>
<DD>

<P CLASS=para>
A date or time field. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The given buffer <tt CLASS=literal>toAppendTo</tt> 
with the formatted representation of the object appended to it. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DateFormat.format(Date, 
StringBuffer, FieldPosition)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method formats the given date and appends the result to the given 
<tt CLASS=literal>StringBuffer</tt>. If <tt CLASS=literal>pos</tt> 
refers to one of the time or date fields, its beginning and ending indexes 
are filled with the beginning and ending positions of the given field in 
the resulting formatted string. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.252">getDateFormatSymbols</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.293">public DateFormatSymbols getDateFormatSymbols()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>DateFormatSymbols</tt> 
object used by this <tt CLASS=literal>SimpleDateFormat</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the <tt CLASS=literal>DateFormatSymbols</tt> 
object that this <tt CLASS=literal>SimpleDateFormat</tt> 
uses internally. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.253">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.294">public int hashCode()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode for this object. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DateFormat.hashCode()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a hashcode for this <tt CLASS=literal>SimpleDateFormat</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.254">parse</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.295">public Date parse(String text, ParsePosition pos)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>text</tt><br>
<DD>

<P CLASS=para>
The string to be parsed.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>pos</tt><br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>ParsePosition</tt> 
object that specifies a position in the string. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Date</tt> object represented 
by the text starting at the given position. 

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>DateFormat.parse(String, 
ParsePosition)</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method parses a date from the given string, starting from the given 
position. After the string has been parsed, the given <tt CLASS=literal>ParsePosition</tt> 
object is updated so that its index is after the parsed text. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.255">setDateFormatSymbols</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.296"><DIV CLASS=screen> <P> <PRE> public void setDateFormatSymbols( DateFormatSymbols newFormatSymbols) </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>newFormatSymbols</tt><br>
<DD>

<P CLASS=para>
The new <tt CLASS=literal>DateFormatSymbols</tt> object to use. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method sets the <tt CLASS=literal>DateFormatSymbols</tt> 
object that this <tt CLASS=literal>SimpleDateFormat</tt> 
uses internally. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.256">toLocalizedPattern</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.297">public String toLocalizedPattern()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The pattern string of this <tt CLASS=literal>SimpleDateFormat</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the pattern string of this <tt CLASS=literal>SimpleDateFormat</tt>, 
localized with the <tt CLASS=literal>DateFormatSymbols</tt> 
object of this <tt CLASS=literal>SimpleDateFormat</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch16-REFSECT2-AUTOID.257">toPattern</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch16-REFSECT3-AUTOID.298">public String toPattern()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The pattern string of this <tt CLASS=literal>SimpleDateFormat</tt>. 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the pattern string of this <tt CLASS=literal>SimpleDateFormat</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.133">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="LEFT">Method</TH>
<TH ALIGN="LEFT">Inherited From</TH>
<TH ALIGN="LEFT">Method</TH>
<TH ALIGN="LEFT">Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>format(Object)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Format</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>format(Date)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>format(Object, StringBuffer, FieldPosition)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getCalendar()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getNumberFormat()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>getTimeZone()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>isLenient()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>parse(String)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>parseObject(String)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Format</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>parseObject(String, ParsePosition)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>setCalendar(Calendar)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>setLenient(boolean)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>setNumberFormat(NumberFormat)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>setTimeZone(TimeZone)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>DateFormat</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>toString()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="LEFT">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch16-REFSECT1-AUTOID.134">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>Calendar</tt>, 
<tt CLASS=literal>Date</tt>, 
<tt CLASS=literal>DateFormat</tt>, 
<tt CLASS=literal>DateFormatSymbols</tt>, 
<tt CLASS=literal>FieldPosition</tt>, 
<tt CLASS=literal>Format</tt>, 
<tt CLASS=literal>Locale</tt>, 
<tt CLASS=literal>ParsePosition</tt>, 
<tt CLASS=literal>String</tt>, 
<tt CLASS=literal>StringBuffer</tt>, 
<tt CLASS=literal>TimeZone</tt> 
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch16_17.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch16_19.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>RuleBasedCollator</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>StringCharacterIterator</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
